package org.compression.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.model.AttrsValueRelate;
import org.model.MagazineAttrs;
import org.model.MagazineValue;
import org.model.SearchModel;
import org.model.TNewMagazine;

@Mapper
public interface TxtInsertMapper {


	
	//@Select("select * from t_search_magazine")
	public List<SearchModel> selectInfo();
	
	//@Insert("insert into t_new_magazine (name) values (#{name})")
//	@Options(useGeneratedKeys=true,keyProperty="id")
	public long	insertBook(@Param("name")String name);
	
	//新增杂志id
	@Select("select id from t_new_magazine order by id desc limit 1")
	public long selectIdMagzine();
	
	
	public void insertValues(@Param("values")List<AttrsValueRelate> values);
	
	
	@Select("select id from t_attrs_values where new_magazine_id=#{id} and value=#{value} ")
	public long selectIdAttrsValues(@Param("id")String id ,@Param("value")String value);
	
	//查询值id 关系表
	@Select("select id,value from t_attrs_values where new_magazine_id=#{id} ")
	public List<MagazineValue> selectTNewMagazine(@Param("id")long id);
	
	//插入值
	public void insertValue(@Param("value")String value,@Param("new_magazine_id") long new_magazine_id);
	
	//插入关系表
	public void insertrelateIds(@Param("attr_id")int i,@Param("value_id")String value_id,@Param("new_magazine_id") long new_magazine_id);
	//插入属性
	public void insertreAttravalue(@Param("name")String name,@Param("new_magazine_id") long new_magazine_id);
	
	//查询新增属性id
	@Select("select id,name from t_magazine_attrs where new_magazine_id=#{id} ")
	public List<MagazineAttrs> selectAttrIds(@Param("id") long new_magazine_id);
	
	//革新路径
	@Update({ "update t_new_magazine set path = #{path}  where id = #{id}" })
    public void updateNewMagazinePath(@Param("path")String path,@Param("id")String id); 
	
	@Update({ "update t_new_magazine set coverpath = #{coverpath}  where id = #{id}" })
    public void updateNewMagazineCoverPath(@Param("coverpath")String coverpath,@Param("id")String id); 
	
	
	
	
	
	
	
	
}







